<!--
	作者：2575202388@qq.com
	时间：2018-10-14
	描述：文化课辅导班管理
-->

<template>
	<div style="width:100%;">
		<div style="background: #fff;">
			<div style="width:100%;float:left;padding-top: 10px;padding-bottom: 10px;">
				<div style="width:10%;text-align: right;float:left;line-height:32px;">年级：</div>
				<div style="width:15%;float:left;">
					<Input v-model="tj.nj"  clearable  style="width: 90%;float:left;" />
				</div>
				<div style="text-align: right;float:left;line-height:32px;padding-left:10px;">班级：</div>
				<div style="width:15%;float:left;">
					<Input v-model="tj.bj"  clearable  style="width: 90%;float:left;" />
				</div>
				<div style="text-align: right;float:left;line-height:32px;padding-left:10px;">科目：</div>
				<div style="width:15%;float:left;">
					<Input v-model="tj.km"  clearable  style="width: 90%;float:left;" />
				</div>
				
				<div style="width:40%;text-align: left;float:left;">
					<Button v-on:click="search()" style="margin-left:1%;background: #ffa500;color:#fff;border:1px solid #ffa500;">搜索</Button>
	            	<Button v-on:click="delhistory()" style="margin-left:1%;background: #EE9572;color:#fff;border:1px solid #EE9572;">移到历史库</Button>
	            	<Button v-on:click="addwhkfdb()" icon="md-add" type="primary" style="background-color: #3fc1c9;border:1px solid #3fc1c9;">新增辅导班</Button>
	            	
	            	<span style="padding-left:5px;padding-right:5px;">是否开启审核功能:</span>
	            	<i-switch v-model="whkshswitch" @on-change="shenhchange" />
				</div>
			</div>
		</div>
		<div>
			<ss :tj="tj" ref="whkfdbss" @getSelection="getSelection"></ss>
		</div>
		<add ref="addwhkfdb" v-on:reload="search()"></add>
	</div>
</template>

<script>
	import ss from "./ss";
	import add from "./add";
	export default {
		name: "studentmanage",
		data() {
			return {
				tj: {
					nj:'',//年级
					bj:'',//班级
					km:'',//科目
					wstate:'0',
				},
				selects:[],
				whkshswitch: true
			}
		},
		methods: {
			search(){
				this.$refs.whkfdbss.load();
			},
	        resettj(){
				this.tj.nj='';
				this.tj.bj='';
				this.tj.km='';
	        },
	        addwhkfdb(){
	        	this.$refs.addwhkfdb.openmodal();
	        },
	      	getSelection(selects){
	      		this.selects=[...selects];
	      	},
	      	delhistory(){
	      		var warr=[];
	      		const sels=this.selects;
	      		for(var i=0;i<sels.length;i++){
	      			const sel={
	      				wid:sels[i].WID
	      			}
	      			warr.push(sel);
	      		}
	      		if(warr.length<=0){
	      			this.$Modal.error({
                        title: "提示",
                        content: "请选择需要移到历史库的辅导班！"
                   });	
                   return;
	      		}
	      		const params={
					wids:JSON.stringify(warr),
				};
                this.$http.post("/host/stgl/whk/delHistoryWhkfdb.html",params)
				.then(result => {
					if(result){
						this.$Modal.success({
                            title: "提示",
                            content: "移动到历史库成功！"
                      });
                       this.search();
					}else{
						this.$Modal.error({
                            title: "提示",
                            content: "移动到历史库失败！"
                       });	
					}
					
				});
				
	        },
	        
	        shenhchange(){	
		      	var whksh="";
		      	if(this.whkshswitch){
		      		whksh="0";
		      	}else{
		      		whksh="1";
		      	}
		      	const params={
		      		whksh:whksh
		      	}
		      	
		     
		      	this.$http.post("/host/stgl/updateSystemInfo.html",params)
				.then(result => {
					if(result){
						this.$Modal.success({
	                        title: "提示",
	                        content: "修改成功！"
	                });
	                this.$store.commit("setUser", {
						CSID:this.user.CSID,
						CSNAME:this.user.CSNAME,
						ROLE: this.user.ROLE,
						STKSH: this.user.STKSH,
						SYSTEMNAME: this.user.SYSTEMNAME,
						UNAME: this.user.UNAME,
						UPWD: this.user.UPWD,
						USERNAME: this.user.USERNAME,
						USID: this.user.USID,
						WHKSH: whksh,
						OTHERSH: this.user.OTHERSH,
						jsessionid:this.user.jsessionid
			      	});
			      	
					}else{
						this.$Modal.error({
	                        title: "提示",
	                        content: "修改失败！"
	                   });	
					}
				});	
	        }
	      
		},
		components: {
			ss,
			add
		},
		mounted(){
			if(this.user.WHKSH=="1"){
				this.whkshswitch=false;
			}else{
				this.whkshswitch=true;
			}
		},
		watch:{
		},
		computed: {
			user: function() {
				return this.$store.state.app.user;
			}
		},
	}
</script>

<style>
</style>